package Blog;

import com.google.common.base.Strings;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

public class BlogCases extends InitAndEnd {


    /**
     * 登录
     */
    @ParameterizedTest
    //@CsvFileSource(resources = "Login.csv")
    @ValueSource(strings ={"lisi","1111","http://114.115.222.15:8080/myblog_list.html"})
    void Login(String username,String password ,String list_url) {
        webDriver.get("http://114.115.222.15:8080/login.html");
        webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
        // 输入账号
        webDriver.findElement(By.cssSelector("#username")).sendKeys(username);
        webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
        // 输入密码
        webDriver.findElement(By.cssSelector("#password")).sendKeys(password);
        webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
        // 点击提交按钮
        webDriver.findElement(By.cssSelector("#submit")).click();
        webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

        String cur_url=webDriver.getCurrentUrl();
        Assertions.assertEquals(list_url,cur_url);

    }
}
